In [1]:
import pandas as pd
from bokeh.plotting import figure
from bokeh.io import show
bin = input("How many minutes would you like to bin by? Type that number followed by a capital T, all enclosed in single quotes ")
Use the pandas resample method to bin the file according to time
In [2]:
df1 = pd.read_csv(input("Name of CO2 file: "))
df1 = df1[['deviceTime_unix','co2_ppm']].copy()
df1 = df1.set_index(['deviceTime_unix'])
df1.index = pd.to_datetime(df1.index, unit='s')
df_binned = df1.resample(bin).mean().dropna().reset_index()
In [3]:
df2 = pd.read_csv(input('Name of Air Quality File: '))
aqType = input("Name the air quality data you would like to use")
df2 = df2[['deviceTime_unix',aqType]].copy()
df2 = df2.set_index(['deviceTime_unix'])
df2.index = pd.to_datetime(df2.index, unit='s')
df2_binned = df2.resample(bin).mean().dropna().reset_index()
In [4]:
p = figure()
p.circle(y=df2_binned['PM25'],x=df_binned['co2_ppm'], color = "red")
show(p)